<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	template="/layout/template.xhtml"
	xmlns:a4j="http://richfaces.org/a4j">
	<ui:define name="stylefms">
		<link href="/stylesheet/theme.css" rel="stylesheet" type="text/css" />
		<link href="/stylesheet/fms.css" rel="stylesheet" type="text/css" />
		<link href="/stylesheet/panel.css" rel="stylesheet" type="text/css" />
		<link href="/stylesheet/debug.css" rel="stylesheet" type="text/css" />
	</ui:define>
	<ui:define name="varProjectName">
		<ui:param name="projectName" value="#{appRes['mod.fms.prd.maintenances.burden']}" />
	</ui:define>


	<ui:define name="body">
	

		<a4j:form id="BurdenGridForm" ajaxSingle="true">
			<rich:panel styleClass="table_back">
				<rich:datascroller align="center" for="BurdenGrid"
					maxPages="15" page="#{dataTableScrollerBean.scrollerPage}"
					renderIfSinglePage="false" />
					
				<rich:dataTable id="BurdenGrid"
					value="#{editBurden.allBurden}" var="burden" rows="10"
					rendered="#{not empty editBurden.allBurden}">
					
					<rich:column>
						<f:facet name="header">Codigo</f:facet>
						<h:outputText value="#{burden.cod}" />
					</rich:column>
					
					<rich:column>
						<f:facet name="header">Descripcion</f:facet>
						<h:outputText value="#{burden.descrip}" />
					</rich:column>
					
					<rich:column>
						<f:facet name="header">Activo</f:facet>
						<h:outputText value="#{convertAssist.booleanToString(burden.status)}" />
					</rich:column>
					
					<rich:column>
						<f:facet name="header">
							<h:outputText styleClass="columnHeader" value="Acciones" />
						</f:facet>
						<h:commandButton id="idCmdBorrar" value="Borrar"
							action="#{editBurden.dataToDelete(burden.id)}"
							image="/img/icons/delete_data.png"
							onclick="if (!confirm('Esta usted seguro que quiere borrar el registro ?')) return false" />
						<rich:toolTip value="Borrar" for="idCmdBorrar" />
						<rich:spacer width="10" />
						<a4j:commandLink id="editAction"  action="#{editBurden.dataToEdit(burden.id)}"
							oncomplete="#{rich:component('modalPanel')}.show()"
							reRender="modalPanel"
							immediate="true">

							<h:graphicImage id="editImg" url="/img/icons/edit.png"
								styleClass="actionsImages" />
						</a4j:commandLink>
						<rich:toolTip value="Editar" for="editAction" />
					</rich:column>

				</rich:dataTable>
			</rich:panel>
			
		</a4j:form>
		<rich:spacer width="10" />	
		<a4j:form id="BurdenForm" ajaxSingle="true">
			
			<rich:panel styleClass="form">
				
				<h:panelGrid>
					<div class="attributes">
						<h:panelGrid>
						
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Codigo</ui:define>
								<h:inputText value="#{editBurden.burden.cod}"
									id="BurdenCode" 
									required="true" size="5"
									requiredMessage="Favor introduzca un codigo"
									validatorMessage="El codigo no puede ser menor a 1 o mayor a 5">
									<f:validateLength minimum="1" maximum="5" />
									<a4j:support event="onblur" />
									
								</h:inputText>
								<div class="msg_container">
								<rich:message for="BurdenCode"/>
								</div>
							</s:decorate>
							<div style="clear: both;" />
							
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Descripcion</ui:define>
								<h:inputText value="#{editBurden.burden.descrip}" label="Descripcion"
									id="BurdenDescrip" 
									required="true" size="30"
									requiredMessage="Favor introduzca el nombre de la descripcion"
									validatorMessage="El nombre no puede ser menor a 1 o mayor a 50">
									<f:validateLength minimum="1" maximum="50" />
									<a4j:support event="onblur" />
									
								</h:inputText>
								<div class="msg_container">
								<rich:message for="BurdenDescrip"/>
								</div>
							</s:decorate>
							<div style="clear: both;" />
						
							<s:decorate template="/layout/input.xhtml">
								<ui:define name="label">Activo</ui:define>
								<h:selectBooleanCheckbox value="#{editBurden.burden.status}" id="BurdenStatus"
								required="false" 
								validatorMessage="El estado no puede ser menor o mayor a 1"
								disabled="true">
								<a4j:support event="onblur" />
								</h:selectBooleanCheckbox>
								
								<div class="msg_container">
									<rich:message for="BurdenStatus"/>
								</div>
							</s:decorate>				
							<div style="clear: both;" />
							 
						</h:panelGrid>
					</div>

						<s:decorate template="/layout/displayButton.xhtml" styleClass="button_form">
							<a4j:commandButton value="Guardar"
								action="#{editBurden.saveNewData()}" reRender="BurdenForm, BurdenGridForm" styleClass="button"/>
							<rich:spacer width="20px" />
							<a4j:commandButton value="Cancelar"
								action="#{editBurden.cancelData()}" reRender="BurdenForm, BurdenGridForm" styleClass="button" />
						</s:decorate>
					
				</h:panelGrid>
			</rich:panel>
		</a4j:form>

		<rich:modalPanel  id="modalPanel" minwidth="800" minheight="400" 
			resizeable="flase" autosized="true"   >
			<f:facet name="header">
				<h:panelGroup>
					<h:outputText value="Actualizar tipo de insumo" />
				</h:panelGroup>
			</f:facet>
			<f:facet name="controls">
				<h:panelGroup>
					<h:graphicImage value="/img/close.png" style="cursor:pointer"
						id="hideEditApp" />
					<rich:componentControl for="modalPanel"
						attachTo="hideEditApp" operation="hide" event="onclick" />
				</h:panelGroup>
			</f:facet>
			<h:panelGroup id="idEditGroup">
			<!--  **** Include of the update page ****  -->
				<a4j:include viewId="/fms/prd/maintenances/prdBurdenEdit.xhtml" />
			</h:panelGroup>
		</rich:modalPanel>


	</ui:define>

</ui:composition>